//获取应用实例
const app = getApp();

Page({

    data: {
        myinfo:""
    },
    onLoad: function (options) {
        wx.login({
            success(res) {
                console.log(res);
            }
        })
        app.func.onPageLoad(this, options);
        this.setData({
            twocolumn: app.func.twocolumn()
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.refresh();
        this.myinfos();
    },


    refresh: function (item) {
        this.banner();
        this.brand();
        this.zone();

        // this.statistics();
        // this.card();

        // this.sku();
        // this.cardplan();
    },

    banner: function () {
        app.func.getPromise('/list/banner')
            .then(([code, res]) => {
                this.setData({banner: res.data});
            })
    },
    brand: function () {
        app.func.getPromise('/list/shortcut')
            .then(([code, res]) => {
                this.setData({brand: res.data,});
            });
    },
    zone: function() {
        app.func.getPromise('/list/zone')
            .then(([code, res]) => {
                this.setData({zone: res.data});
            })
    },


    statistics:function () {
        app.func.getPromise('/list/statistics')
            .then(([code,res])=>{
                this.setData({ statistics:res.data });
            })
    },
    card: function () {
        app.func.getPromise('/list/card/0')
            .then(([code, res]) => {
                this.setData({card1: res.data})
            }).then(() => {
            app.func.getPromise('/list/card/1')
                .then(([code, res]) => {
                    this.setData({card2: res.data});
                })
        })
    },
    sku:function(){
        app.func.getPromise('/list/home/gifts')
            .then(([code, res]) => {
                this.setData({gifts: res.data, key: res.key});
            })
    },
    myinfos(){
        app.func.getPromise('/my/info')
                .then(([code, res]) => {
                this.setData({
                        myinfo: res.message
                });
        })
    },

    cardplan: function () {
        app.func.getPromise('/list/cardplan/0?length=3')
            .then(([code, res]) => {
                this.setData({list: res.data});
            })
    },

})